package com.example.behaviour;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.example.behaviour.IM.NettyServer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;


@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.example.apis")
@MapperScan(basePackages = {"com.example.acl.mapper","com.example.user.mapper","com.example.behaviour.mapper"})
@ComponentScan(basePackages = {"com.example.common","com.example.user","com.example.behaviour"})
public class BehaviourApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(BehaviourApplication.class,args);
    }

    @Autowired
    private NettyServer nettyServer;

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

    @Override
    public void run(String... strings){
        nettyServer.start();
    }
}
